package com.example.aigc_education.ws.handler;

import com.example.aigc_education.integration.request.ChatMessageRequestV2;
import com.example.aigc_education.rpc.api.v2.ChatServiceProto;
import com.example.aigc_education.ws.response.MapMessage;

public class MapMessageHandler extends AbstractMessageHandler {

    @Override
    public ChatMessageRequestV2 handle(ChatServiceProto.ChatMessage chatMessage) {
        MapMessage message = new MapMessage();
        message.setNodes(chatMessage.getContents(0).getMap().getNodes());
        message.setRelations(chatMessage.getContents(0).getMap().getRelations());

        return ChatMessageRequestV2.builder()
                .userId(String.valueOf(chatMessage.getUserId()))
                .type(chatMessage.getContents(0).getType())
                .role(ChatMessageRequestV2.Role.AI)
                .content(message)
                .messageId(chatMessage.getMessageId())
                .convId(String.valueOf(chatMessage.getConvId()))
                .build();
    }

    @Override
    protected int getRole() {
        return ChatServiceProto.Role.AI_VALUE;
    }

    @Override
    protected String getType() {
        return "map";
    }
}
